'use strict';
game.import('character', function (lib, game, ui, get, ai, _status) {
	return {
		name: 'classic',
		connect: true,
		characterSort: {
			classic: {
				classic_qian: ['menghuo', 'pangtong', 'xiahouyuan', 'xunyu', 'taishici', 'yufan', 'diaochan', 'dongzhuo'],
				classic_kun: ['machao', 'xushu', 'caoren', 'caozhi', 'zhoutai', 'zhangzhaozhanghong', 'huaxiong', 'simayi'],
			},
		},
		character: {
			//qian
			menghuo: ['male', 'shu', '2/4', ['huoshou', 'zaiqi'], null, 2, ['Dshuchu', 'Dhuifu']],
			pangtong: ['male', 'shu', 3, ['tianmou', 'kanpo', 'niepan'], null, 3, ['Dkongchang', 'Dfangyu']],
			xiahouyuan: ['male', 'wei', 4, ['shensu'], null, 2, ['Dshuchu']],
			xunyu: ['male', 'wei', 3, ['quhu', 'jieming'], null, 4, ['Dfuzhu', 'Dfangyu']],
			taishici: ['male', 'wu', 4, ['tianyi'], null, 2, ['Dshuchu']],
			yufan: ['male', 'wu', 3, ['zongxuan', 'zhiyan'], null, 4, ['Dfuzhu', 'Dkongchang']],
			diaochan: ['female', 'qun', 3, ['lijian', 'biyue'], null, 3, ['Dkongchang']],
			dongzhuo: ['male', 'qun', 8, ['tuicheng', 'yaoling', 'shicha', 'yongquan'], ['zhu'], 3, ['Dkongchang', 'Dfangyu', 'Dfuzhu']],

			machao: ['male', 'shu', 4, ['tieji', 'mashu'], null, 2, ['Dshuchu']],
			xushu: ['male', 'shu', 3, ['wuyan', 'jujian'], null, 3, ['Dfuzhu', 'Dfangyu']],
			caoren: ['male', 'wei', 4, ['jushou'], null, 2, ['Dkongchang', 'Dfangyu']],
			caozhi: ['male', 'wei', 3, ['luoying', 'jiushi'], null, 3, ['Dkongchang', 'Dfangyu']],
			zhoutai: ['male', 'wu', 4, ['buqu', 'fenji'], null, 2, ['Dfangyu', 'Dfuzhu']],
			zhangzhaozhanghong: ['male', 'wu', 3, ['zhijian', 'guzheng'], null, 3, ['Dfuzhu', 'Dkongchang']],
			huaxiong: ['male', 'qun', 6, ['yaowu', 'shiyong'], null, 4, ['Dfangyu', 'Dshuchu']],
			simayi: ['male', 'jin', 3, ['fankui', 'quanbian'], null, 3, ['Dkongchang', 'Dshuchu']],
		},
		characterIntro: {
			menghuo: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			pangtong: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			xiahouyuan: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			xunyu: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			taishici: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			yufan: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			diaochan: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			dongzhuo: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',

			machao: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			xushu: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			caoren: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			caozhi: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			zhoutai: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			zhangzhaozhanghong: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			huaxiong: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
			simayi: '<li>立绘：三国杀官方<br><li>配音：三国杀官方',
		},
		card: {

		},
		skill: {
			huoshou: {
				audio: "huoshou1",
				locked: true,
				group: ['huoshou1', 'huoshou2', 'huoshou3', 'huoshou4', 'huoshou5'],
				preHidden: ['huoshou1', 'huoshou2', 'huoshou3', 'huoshou4', 'huoshou5'],
				ai: {
					effect: {
						target: function (card, player, target) {
							if (card.name == 'nanman') return 0;
						}
					}
				}
			},
			huoshou1: {
				audio: 2,
				trigger: { target: 'useCardToBefore' },
				forced: true,
				priority: 15,
				filter: function (event, player) {
					return (event.card.name == 'nanman');
				},
				content: function () {
					trigger.cancel();
				},
			},
			huoshou2: {
				trigger: { global: 'respond' },
				forced: true,
				silent: true,
				popup: false,
				filter: function (event, player) {
					return event.getParent(2).card && event.getParent(2).card.name == 'nanman' && event.getParent(2).player == player;
				},
				content: function () {
					trigger.player.draw();
				}
			},
			huoshou3: {
				trigger: { source: 'damage' },
				forced: true,
				silent: true,
				popup: false,
				filter: function (event, player) {
					return event.card&&event.card.name == 'nanman';
				},
				content: function () {
					player.storage.huoshou.push(trigger.player);
				},
			},
			huoshou4: {
				trigger: { player: 'useCardAfter' },
				forced: true,
				silent: true,
				popup: false,
				filter: function (event, player) {
					return event.card.name == 'nanman' && player.storage.huoshou.length >= 2;
				},
				content: function () {
					player.chooseDrawRecover(1, 1);
					delete player.storage.huoshou;
				},
			},
			huoshou5: {
				trigger: { player: 'useCardBegin' },
				forced: true,
				filter: function (event, player) {
					return event.card.name == 'nanman';
				},
				content: function () {
					player.storage.huoshou = [];
				},
			},
			zaiqi: {
				audio: 2,
				group: 'zaiqi1',
				direct: true,
				trigger: { player: ['phaseUseBegin', 'dying'] },
				filter: function (event, player) {
					return player.hasMark('zaiqi') && !player.hasSkill('zaiqi2') && player.countCards('h');
				},
				content: function () {
					'step 0'
					player.chooseCard('###再起###是否将一张手牌当【南蛮入侵】使用？', 'h').set('ai', function (card) {
						if (event.name == 'dying') return  20 - get.value(card);
						if (game.players.length == 2) return  6 - get.value(card);
						var targets = game.filterPlayer(function (current) {
							return player.canUse('wanjian', current);
						});
						var num = 0;
						for (var i = 0; i < targets.length; i++) {
							var eff = get.sgn(get.effect(targets[i], { name: 'nanman' }, player, player));
							if (targets[i].hp == 1) {
								eff *= 1.5;
							}
							num += eff;
						}
						if (player.storage.zaiqi < 3) num -= 1;
						if(num<=0) return false;
						else  return  6 - get.value(card);
					});
					'step 1'
					if(result.bool){
						player.logSkill('zaiqi');
						player.removeMark('zaiqi');
						//player.useCard({name:'nanman'},result.cards[0]).audio=false;
						player.chooseUseTarget({ name: 'nanman' },[result.cards[0]], true, 'noTargetDelay', 'nodelayx').audio=false;
						player.addTempSkill('zaiqi2');
					}
					
				},
				/*check: function (event, player) {
					if (event.name == 'dying') return true;
					if (game.players.length == 2) return true;
					var targets = game.filterPlayer(function (current) {
						return player.canUse('wanjian', current);
					});
					var num = 0;
					var cnt = 0;
					for (var i = 0; i < targets.length; i++) {
						var eff = get.sgn(get.effect(targets[i], { name: 'nanman' }, player, player));
						if (targets[i].hp == 1) {
							eff *= 1.5;
						}
						num += eff;
					}
					if (player.storage.zaiqi < 3) num -= 1;
					return num;
				},*/
				marktext: "起",
				intro: {
					name: "起",
					content: '共有$个标记',
				},
			},
			zaiqi1: {
				forced: true,
				trigger: {
					global: "phaseBefore",
				},
				filter: function (event, player) {
					if (!player.storage.zaiqi_inited) return true;
				},
				content: function () {
					if (!player.storage.zaiqi_inited) {
						player.storage.zaiqi_inited = true;
						player.addMark('zaiqi', 7);
					}
				},
			},
			zaiqi2: {},

			tianmou: {
				audio: 2,
				enable: 'phaseUse',
				usable: 1,
				filter: function (event, player) {
					if (player.countCards('h') == 0) return false;
					return game.hasPlayer(function (current) {
						return current.countCards('h');
					});
				},
				filterTarget: function (card, player, target) {
					return player.canCompare(target);
				},
				content: function () {
					"step 0"
					player.chooseToCompare(target);
					"step 1"
					if (result.bool) {
						var list = ['guohe', 'huogong', 'tiesuo'];
						player.chooseButton([get.prompt('tianmou'), [list, 'vcard']]).set('ai', function (button) {
							var num1 = -5, num2 = 0, num3 = 0, num4 = 0;
							for (var i = 0; i < game.players.length; i++) {
								if (game.players[i] == player) continue;
								num1 = Math.max(num1, get.effect(game.players[i], { name: 'guohe' }, player, player));
								var tmp1 = get.effect(game.players[i], { name: 'huogong' }, player, player);
								if (player.countCards('h') < 2) tmp1 *= 0.3;
								num2 = Math.max(num2, tmp1);
								num4 = Math.max(num4, get.effect(game.players[i], { name: 'tiesuo' }, player, player));
							}
							if (button.name == 'guohe') return num1;
							if (button.name == 'huogong') return num2;
							if (button.name == 'tiesuo') return num4;
						});
					}
					else {
						player.addTempSkill('tianmou2');
						event.finish();
					}
					"step 2"
					var name = result.links[0][2];
					player.chooseUseTarget({ name: name });
				},
				ai: {
					order: 4,
					result: {
						target: function (player, target) {
							var num = target.countCards('h');
							if (num == 1) return -2;
							if (num == 2) return -1.3;
							return -0.5
						},
						player: function (player) {
							var num = player.countCards('h');
							if (num > player.hp) return 0;
							if (num == 1) return -2;
							if (num == 2) return -1;
							return -0.5;
						},
					},
					expose: 0.2
				}
			},
			tianmou2: {
				mod: {
					cardEnabled: function (card) { if (get.type(card, 'trick') == 'trick') return false }
				},
				charlotte: true,
			},
			niepan: {
				audio: 2,
				audioname: ['re_pangtong'],
				unique: true,
				enable: 'chooseToUse',
				mark: true,
				limited: true,
				skillAnimation: true,
				animationStr: '涅盘',
				animationColor: 'fire',
				init: function (player) {
					player.storage.niepan = false;
				},
				filter: function (event, player) {
					if (player.storage.niepan) return false;
					if (event.type == 'dying') {
						if (player != event.dying) return false;
						return true;
					}
					return false;
				},
				content: function () {
					'step 0'
					player.awakenSkill('niepan');
					player.storage.niepan = true;
					player.discard(player.getCards('hej'));
					'step 1'
					player.link(false);
					'step 2'
					player.turnOver(false);
					'step 3'
					player.draw(3);
					'step 4'
					if (player.hp < 3) {
						player.recover(3 - player.hp);
					}
				},
				ai: {
					order: 0.5,
					skillTagFilter: function (player, tag, target) {
						if (player != target || player.storage.niepan) return false;
					},
					save: true,
					result: {
						player: function (player) {
							if (player.hp <= 0) return 10;
							if (player.hp <= 1 && player.countCards('he') <= 1) return 10;
							return 0;
						}
					},
					threaten: function (player, target) {
						if (!target.storage.niepan) return 0.6;
					}
				},
				intro: {
					content: 'limited'
				}
			},

			shensu: {
				audio: 'shensu1',
				group: ['shensu1', 'shensu2']
			},
			shensu1: {
				audio: 2,
				trigger: { player: 'phaseJudgeBefore' },
				direct: true,
				filter: function (event, player) {
					if (event.nocancel) return false;
					return true;
				},
				content: function () {
					"step 0"
					var check = player.countCards('h') > 2 || game.hasPlayer(function (current) {
						return get.attitude(player, current) < 0 && current.hp == 1;
					});
					player.chooseTarget(get.prompt("shensu"), "跳过判定阶段和摸牌阶段，视为对一名其他角色使用一张【刺杀】", function (card, player, target) {
						if (player == target) return false;
						return player.canUse({ name: 'sha' }, target, false);
					}).set('check', check).set('ai', function (target) {
						if (!_status.event.check) return 0;
						return get.effect(target, { name: 'sha', nature: 'stab' }, _status.event.player);
					}).setHiddenSkill('shensu1');
					"step 1"
					if (result.bool) {
						player.logSkill('shensu1', result.targets);
						player.useCard({ name: 'sha', nature: 'stab', isCard: true }, result.targets[0], false);
						trigger.cancel();
						player.skip('phaseDraw');
					}
				}
			},
			shensu2: {
				audio: 'shensu1',
				trigger: { player: 'phaseUseBefore' },
				direct: true,
				filter: function (event, player) {
					return player.countCards('he', function (card) {
						if (_status.connectMode) return true;
						return get.type(card) == 'equip';
					}) > 0;
				},
				content: function () {
					"step 0"
					var check = player.needsToDiscard() || game.hasPlayer(function (current) {
						return get.attitude(player, current) < 0 && current.hp == 1;
					});
					player.chooseCardTarget({
						prompt: get.prompt('shensu'),
						prompt2: "弃置一张装备牌并跳过出牌阶段，视为对一名其他角色使用一张【刺杀】",
						filterCard: function (card, player) {
							return get.type(card) == 'equip' && lib.filter.cardDiscardable(card, player)
						},
						position: 'he',
						filterTarget: function (card, player, target) {
							if (player == target) return false;
							return player.canUse({ name: 'sha' }, target, false);
						},
						ai1: function (card) {
							if (_status.event.check) return 0;
							return 6 - get.value(card);
						},
						ai2: function (target) {
							if (_status.event.check) return 0;
							return get.effect(target, { name: 'sha', nature: 'stab' }, _status.event.player);
						},
						check: check
					}).setHiddenSkill('shensu2');
					"step 1"
					if (result.bool) {
						player.logSkill('shensu2', result.targets);
						player.discard(result.cards[0]);
						player.useCard({ name: 'sha', nature: 'stab', isCard: true }, result.targets[0], false);
						trigger.cancel();
					}
				}
			},

			quhu: {
				audio: 2,
				enable: 'phaseUse',
				usable: 1,
				filter: function (event, player) {
					if (player.countCards('h') == 0) return false;
					return game.hasPlayer(function (current) {
						return current.hp > player.hp && current.countCards('h');
					});
				},
				filterTarget: function (card, player, target) {
					return target.hp > player.hp && player.canCompare(target);
				},
				content: function () {
					"step 0"
					player.chooseToCompare(target);
					"step 1"
					if (result.bool) {
						if (game.hasPlayer(function (player) {
							return player != target && target.inRange(player);
						})) {
							player.chooseTarget(function (card, player, target) {
								var source = _status.event.source;
								return target != source && source.inRange(target);
							}, true).set('ai', function (target) {
								return get.damageEffect(target, _status.event.source, player);
							}).set('source', target);
						}
						else {
							event.finish();
						}
					}
					else {
						player.damage(target);
						event.finish();
					}
					"step 2"
					if (result.bool && result.targets && result.targets.length) {
						target.line(result.targets[0], 'green');
						result.targets[0].autoDamage(1, target);
					}
				},
				ai: {
					order: 0.5,
					result: {
						target: function (player, target) {
							var att = get.attitude(player, target);
							var oc = (target.countCards('h') == 1);
							if (att > 0 && oc) return 0;
							var players = game.filterPlayer();
							for (var i = 0; i < players.length; i++) {
								if (players[i] != target && players[i] != player &&
									target.inRange(players[i])) {
									if (get.damageEffect(players[i], target, player) > 0) {
										return att > 0 ? att / 2 : att - (oc ? 5 : 0);
									}
								}
							}
							return 0;
						},
						player: function (player, target) {
							if (target.hasSkillTag('jueqing', false, target)) return -10;
							var mn = 1;
							var hs = player.getCards('h');
							for (var i = 0; i < hs.length; i++) {
								mn = Math.max(mn, hs[i].number);
							}
							if (mn <= 11 && player.hp < 2) return -20;
							var max = player.maxHp - hs.length;
							var players = game.filterPlayer();
							for (var i = 0; i < players.length; i++) {
								if (get.attitude(player, players[i]) > 2) {
									max = Math.max(Math.min(5, players[i].hp) - players[i].countCards('h'), max);
								}
							}
							switch (max) {
								case 0: return mn == 13 ? 0 : -20;
								case 1: return mn >= 12 ? 0 : -15;
								case 2: return 0;
								case 3: return 1;
								default: return max;
							}
						}
					},
					expose: 0.2
				}
			},
			jieming: {
				audio: 2,
				trigger: { player: 'damageEnd' },
				direct: true,
				content: function () {
					"step 0"
					event.count = trigger.num;
					"step 1"
					event.count--;
					player.chooseTarget(get.prompt2('jieming'), function (card, player, target) {
						return target.countCards('h') < Math.min(target.maxHp, 5);
					}).set('ai', function (target) {
						var att = get.attitude(_status.event.player, target);
						if (target.hasSkillTag('nogain')) att /= 6;
						if (att > 2) {
							return Math.min(5, target.maxHp) - target.countCards('h');
						}
						return att / 3;
					});
					"step 2"
					if (result.bool) {
						player.logSkill('jieming', result.targets);
						for (var i = 0; i < result.targets.length; i++) {
							result.targets[i].drawTo(Math.min(5, result.targets[i].maxHp));
						}
						if (event.count) event.goto(1);
					}
				},
				ai: {
					maixie: true,
					maixie_hp: true,
					effect: {
						target: function (card, player, target, current) {
							if (get.tag(card, 'damage') && target.hp > 1) {
								if (player.hasSkillTag('jueqing', false, target)) return [1, -2];
								var max = 0;
								var players = game.filterPlayer();
								for (var i = 0; i < players.length; i++) {
									if (get.attitude(target, players[i]) > 0) {
										max = Math.max(Math.min(5, players[i].hp) - players[i].countCards('h'), max);
									}
								}
								switch (max) {
									case 0: return 2;
									case 1: return 1.5;
									case 2: return [1, 2];
									default: return [0, max];
								}
							}
							if ((card.name == 'tao' || card.name == 'caoyao') &&
								target.hp > 1 && target.countCards('h') <= target.hp) return [0, 0];
						}
					},
				}
			},

			tianyi: {
				audio: 2,
				enable: 'phaseUse',
				usable: 1,
				filterTarget: function (card, player, target) {
					return player.canCompare(target);
				},
				filter: function (event, player) {
					return player.countCards('h') > 0;
				},
				content: function () {
					"step 0"
					player.chooseToCompare(target);
					"step 1"
					if (result.bool) {
						player.addTempSkill('tianyi2');
					}
					else {
						player.addTempSkill('tianyi3');
					}
					'step 2'
					var list=[];
					if(result.player.name=='sha') list.push(result.player);
					if(result.target.name=='sha') list.push(result.target);
					if(list.length) player.gain(list,'gain2');
				},
				ai: {
					order: function (name, player) {
						var cards = player.getCards('h');
						if (player.countCards('h', 'sha') == 0) {
							return 1;
						}
						for (var i = 0; i < cards.length; i++) {
							if (cards[i].name != 'sha' && cards[i].number > 11 && get.value(cards[i]) < 7) {
								return 9;
							}
						}
						return get.order({ name: 'sha' }) - 1;
					},
					result: {
						player: function (player) {
							if (player.countCards('h', 'sha') > 0) return 0.6;
							var num = player.countCards('h');
							if (num > player.hp) return 0;
							if (num == 1) return -2;
							if (num == 2) return -1;
							return -0.7;
						},
						target: function (player, target) {
							var num = target.countCards('h');
							if (num == 1) return -1;
							if (num == 2) return -0.7;
							return -0.5
						},
					},
					threaten: 1.3
				}
			},
			tianyi2: {
				mod: {
					targetInRange: function (card, player, target, now) {
						if (card.name == 'sha') return true;
					},
					selectTarget: function (card, player, range) {
						if (card.name == 'sha' && range[1] != -1) range[1]++;
					},
					cardUsable: function (card, player, num) {
						if (card.name == 'sha') return num + 1;
					}
				},
				charlotte: true,
			},
			tianyi3: {
				mod: {
					cardEnabled: function (card) { if (card.name == 'sha') return false }
				},
				charlotte: true,
			},

			zongxuan: {
				audio: 2,
				trigger: { player: 'loseAfter' },
				forced: true,
				filter: function (event, player) {
					if (event.type != 'discard') return false;
					for (var i = 0; i < event.cards2.length; i++) {
						if (get.position(event.cards2[i]) == 'd') {
							return true;
						}
					}
					return false;
				},
				content: function () {
					"step 0"
					var cards = [];
					for (var i = 0; i < trigger.cards2.length; i++) {
						if (get.position(trigger.cards2[i], true) == 'd') {
							cards.push(trigger.cards2[i]);
						}
					}
					var next = player.chooseToMove('纵玄：将至少一张牌置于牌堆顶', true);
					next.set('list', [
						['本次弃置的牌', cards],
						['牌堆顶'],
					]);
					next.set('filterOk', function (moved) {
						return moved[1].length > 0;
					});
					next.set('processAI', function (list) {
						var cards = list[0][1].slice(0), cards3;
						cards3 = cards.randomGet();
						return [[], [cards3]];
					})
					'step 1'
					if (result.bool) {
						var cards = result.moved[1];
						game.log(player, '将', cards, '置于了牌堆顶');
						while (cards.length) ui.cardPile.insertBefore(cards.pop().fix(), ui.cardPile.firstChild);
						game.updateRoundNumber();
					}
				},
				mod: {
					maxHandcardBase: function (player, num) {
						return num - 2;
					}
				}
			},
			zhiyan: {
				audio: 2,
				trigger: { player: 'phaseJieshuBegin' },
				frequent: true,
				content: function () {
					'step 0'
					player.storage.zhiyan = [];
					"step 1"
					player.chooseTarget(get.prompt('zhiyan'), '令一名未选择过的角色展示牌堆顶的一张牌。', function (card, player, target) {
						return !player.storage.zhiyan.contains(target);
					}).set('ai', function (target) {
						var cards = get.cards();
						ui.cardPile.insertBefore(cards[0], ui.cardPile.firstChild);
						game.updateRoundNumber();
						var players1 = game.filterPlayer(function (target) {
							return get.attitude(_status.event.player, target) >= 0 && !_status.event.player.storage.zhiyan.contains(target) && target != _status.event.player;
						});
						var players2 = game.filterPlayer(function (target) {
							return get.attitude(_status.event.player, target) < 0 && !_status.event.player.storage.zhiyan.contains(target);
						});
						if (!players1.length && !players2.length && target == _status.event.player) return true;
						if (get.type(cards[0]) == 'basic') {
							if (players1.contains(target))
								return true;
						}
						else {
							if (players2.contains(target))
								return true;
						}
					});
					"step 2"
					if (result.bool) {
						player.storage.zhiyan.push(result.targets[0]);
						event.target = result.targets[0];
						event.cards = get.cards();
						event.player = player;
						event.target.showCards(event.cards);
						if (get.type(event.cards[0]) == 'basic') {
							event.target.chooseControlList(['你获得该牌，然后令' + get.translation(player) + '重复此流程', '令' + get.translation(player) + '摸两张牌'], true, function (event, player) {
								if (event.cards[0].name == 'du') return 1;
								if (player == event.player) return 1;

								if (get.attitude(player, event.player) >= 0) return 0;
								else if (get.value(event.cards[0]) >= 5) return 0;
								return 1;
							});
						}
						else {
							event.target.chooseControlList(['你弃置一张牌，然后令' + get.translation(player) + '重复此流程', '令' + get.translation(player) + '获得此牌并摸一张牌'], true, function (event, player) {
								if (get.attitude(player, event.player) >= 0) return 1;
								if (player.hasCard(function (card) {
									return get.value(card) < 4;
								}, 'h') && get.value(event.cards[0]) >= 7) return 0;
								return 1;
							});
						}
					}
					else {
						event.finish();
					}
					"step 3"
					if (get.type(event.cards[0]) == 'basic') {
						if (result.index == 0) {
							event.target.gain(event.cards, 'gain2');
							game.log('#b' + get.translation(event.target), '获得了', '#y' + get.translation(event.cards[0]));
							event.goto(1);
						}
						else {
							cards[0].discard();
							player.draw(2);
						}
					}
					else {
						if (result.index == 0) {
							if (event.target.countCards('hs') > 0)
								event.target.chooseToDiscard('直言：弃置一张牌，然后' + get.translation(player) + '重复此流程', true).set('ai', function (card) {
									return 4 - get.value(card);
								});
							cards[0].discard();
							event.goto(1);
						}
						else {
							player.gain(event.cards, 'gain2');
							game.log('#b' + get.translation(player), '获得了', '#y' + get.translation(event.cards[0]));
							player.draw(2);
						}
					}
				},
				ai: {
					threaten: 1.4
				}
			},

			lijian: {
				audio: 2,
				enable: 'phaseUse',
				usable: 1,
				filter: function (event, player) {
					return game.countPlayer(function (current) {
						return current != player && current.hasSex('male');
					}) > 1;
				},
				check: function (card) { return 10 - get.value(card) },
				filterCard: true,
				position: 'hs',
				content: function () {
					'step 0'
					var list = ['令一名男性角色视为对另一名男性角色使用一张【决斗】。'];
					if (game.countPlayer(function (current) {
						return current != player && current.hasSex('male') && current.countCards('h');
					}) > 1) list.push('令一名男性角色与另一名男性角色拼点。');
					player.chooseControlList('离间', list, true, function (event, player) {
						var cnt = 0;
						for (var i = 0; i < game.players.length; i++) {
							if (game.players[i] == player || !game.players[i].hasSex('male') || get.attitude(player, game.players[i]) >= 0) continue;
							if (game.players[i].hp == 1) return 0;
							if (!game.players[i].countCards('h')) continue;
							cnt++;
						}
						if (cnt < 2) return 0;
						else return Math.round(Math.random() * 2);
					})
					'step 1'
					if (result.index == 0) {
						event.num = 0;
						player.chooseTarget('令一名男性角色视为对另一名男性角色使用一张【决斗】。', function (card, player, target) {
							if (player == target) return false;
							if (!target.hasSex('male')) return false;
							if (ui.selected.targets.length == 1) {
								return target.canUse({ name: 'juedou' }, ui.selected.targets[0]);
							}
							return true;
						}).set('ai', function (target) {
							if (ui.selected.targets.length == 0) {
								if (target.hp == 1) return (-get.attitude(player, target)) * 1.5;
								return -get.attitude(player, target);
							}
							else {
								if (target.hp == 1) return -get.effect(target, { name: 'juedou' }, ui.selected.targets[0], target) * 1.5;
								return -get.effect(target, { name: 'juedou' }, ui.selected.targets[0], target);
							}
						}).set('targetprompt', ['先出杀', '后出杀']).set('selectTarget', 2).set('multitarget', true);
					}
					else if (result.index == 1) {
						event.num = 1;

						player.chooseTarget('令一名男性角色与另一名男性角色拼点。', function (card, player, target) {
							if (player == target) return false;
							if (!target.hasSex('male')) return false;
							if (!target.countCards('h')) return false;
							if (ui.selected.targets.length == 1) {
								return target.canCompare(ui.selected.targets[0]);
							}
							return true;
						}).set('ai', function (target) {
							return -get.attitude(player, target);
						}).set('targetprompt', ['拼点发起者', '拼点接受者']).set('selectTarget', 2).set('multitarget', true);
					}
					else {
						event.finish();
					}
					'step 2'
					if (event.num == 0) {
						if (result.bool) {
							player.line(result.targets[0], 'green');
							result.targets[0].line(result.targets[1], 'green');
							result.targets[1].useCard({ name: 'juedou', isCard: true }, 'nowuxie', result.targets[0], 'noai').animate = false;
							game.delay(0.5);
							event.finish();
						}
					}
					else {
						if (result.bool) {
							player.line(result.targets[0], 'green');
							result.targets[0].line(result.targets[1], 'green');
							result.targets[0].chooseToCompare(result.targets[1]);
							event.player = result.targets[0];
							event.target = result.targets[1];
							game.delay(0.5);
						}
					}
					//				'step 3'
					//				if(result.bool){
					//					if(event.target.countDiscardableCards(event.player, 'hs')) 
					//						event.player.discardPlayerCard('hs', event.target, true);
					//				}
					//				else {
					//					if(event.player.countDiscardableCards(event.target, 'hs')) 
					//						event.target.discardPlayerCard('hs', event.player, true);
					//				}
				},
				ai: {
					order: 8,
					result: {
						player: function (player) {
							var cnt = 0;
							for (var i = 0; i < game.players.length; i++) {
								if (game.players[i] == player || !game.players[i].hasSex('male') || get.attitude(player, game.players[i]) >= 0) continue;
								cnt++;
							}
							if (cnt >= 2) return cnt;
							else return 0;
						}
					},
					expose: 0.4,
					threaten: 2.5,
				}
			},
			biyue: {
				audio: 2,
				trigger: { player: 'phaseJieshuBegin' },
				direct: true,
				content: function () {
					'step 0'
					player.chooseBool(get.prompt2('biyue')).set('ai', function (event, player) {
						var cards = player.getCards('h');
						if (cards.length != 3) return true;
						else {
							var cnt = 0;
							for (var i = 0; i < cards.length; i++) {
								if ((get.type(cards[i]) == 'basic' && cards[i].name != 'du') || cards[i].name == 'wuxie') cnt++;
							}
							if (cnt >= 2) return false;
						}
					});
					'step 1'
					if (result.bool) {
						player.logSkill('biyue');
						if (!player.storage.biyue) player.storage.biyue = 0;
						player.draw(player.storage.biyue + 1);
						player.removeMark('biyue', player.storage.biyue);
					}
					else {
						player.addMark('biyue');
					}
				},
				marktext: "月",
				intro: {
					name: "月",
					content: '共有$个标记',
				},
			},

			tuicheng: {
				audio: 2,
				enable: 'phaseUse',
				usable: 1,
				discard: false,
				lose: false,
				delay: false,
				filter: function (event, player) {
					return player.hp > 0;
				},
				filterTarget: function (card, player, target) {
					if (player == target) return false;
					return player.canUse({ name: 'tuixinzhifu' }, target);
				},
				content: function () {
					player.loseHp();
					player.useCard({ name: 'tuixinzhifu' }, target).audio = false;
					player.storage.shicha = true;
				},
				ai: {
					result: {
						target: function (player, target) {
							return get.effect(target, { name: 'tuixinzhifu' }, player, target);
						},
						player: function (player) {
							if (player.hp == 1) return -50;
							if (player.hp <= 3) return -6;
							if (player.hp == player.maxHp) return 2;
							return 0;
						},
					},
					order: 9,
				}
			},
			yaoling: {
				audio: 2,
				direct: true,
				trigger: { player: ['phaseUseEnd'] },
				filter: function (event, player) {
					return game.hasPlayer(function (current) {
						return game.hasPlayer(function (current2) {
							return lib.filter.filterTarget({ name: 'sha' }, current, current2);
						})
					});
				},
				content: function () {
					'step 0'
					player.chooseTarget(get.prompt2('yaoling'), function (card, player, target) {
						if (ui.selected.targets.length == 0) {
							if (player == target) return false;
							if (!target.countCards('he')) return false;
						}
						if (ui.selected.targets.length == 1) {
							return lib.filter.filterTarget({ name: 'sha' }, ui.selected.targets[0], target);
						}
						return true;
					}).set('ai', function (target) {
						if (player.maxHp <= 3) return false;
						if (ui.selected.targets.length == 0) {
							if (get.attitude(player, target) >= 0 && target.countCards('h', { name: 'sha' }) > 0 && game.hasPlayer(function (current) {
								return lib.filter.filterTarget({ name: 'sha' }, target, current) && get.effect(target, { name: 'sha' }, current, target) > 0;
							})) {
								return get.attitude(player, target);
							}
							return -get.attitude(player, target);
						}
						else {
							//	console.log(ui.selected.targets[0],target,get.effect(ui.selected.targets[0], { name: 'sha' }, target, ui.selected.targets[0]),get.attitude(ui.selected.targets[0], target));
							if (get.attitude(ui.selected.targets[0], target) < 0) return get.effect(ui.selected.targets[0], { name: 'sha' }, target, ui.selected.targets[0]);
							return -get.effect(ui.selected.targets[0], { name: 'sha' }, target, ui.selected.targets[0]);
						}
					}).set('targetprompt', ['耀令目标', '出杀目标']).set('selectTarget', 2).set('multitarget', true).set('line', true);
					'step 1'
					if (result.bool) {
						player.loseMaxHp();
						player.storage.shicha = true;
						player.logSkill('yaoling', result.targets, undefined, undefined, true);
						event.target1 = result.targets[0];
						event.target2 = result.targets[1];
						event.target1.chooseToUse(function (card, player, event) {
							if (get.name(card) != 'sha') return false;
							return lib.filter.filterCard.apply(this, arguments);
						}, '耀令：对' + get.translation(event.target2) + '使用一张杀，或令' + get.translation(player) + '弃置你的一张牌').set('targetRequired', true).set('complexSelect', true).set('filterTarget', function (card, player, target) {
							var target2=_status.event.getParent().target2;
							if (target != target2 && !ui.selected.targets.contains(target2)) return false;
							return lib.filter.filterTarget.apply(this, arguments);
						});
					}
					else event.finish();
					"step 2"
					if (result.bool == false && event.target1.countCards('he') > 0) {
						player.discardPlayerCard(event.target1, 'he', true);
					}
					else {
						event.finish();
					}
				},
				ai: {
					threaten: 2,
				}
			},
			shicha: {
				forced: true,
				audio: 2,
				group: ['shicha2'],
				trigger: { player: ['phaseDiscardBegin'] },
				filter: function (event, player) {
					return !player.storage.shicha;
				},
				content: function () {
					trigger.audioed = true;
				},
				mod: {
					maxHandcardBase: function (player, num) {
						if (!player.storage.shicha)
							return 1;
					}
				}
			},
			shicha2: {
				forced: true,
				pupup: false,
				silent: true,
				trigger: { player: ['phaseDiscardEnd'] },
				filter: function (event, player) {
					return player.storage.shicha;
				},
				content: function () {
					player.storage.shicha = false;
				},
			},
			yongquan: {
				unique: true,
				zhuSkill: true,
				frequent: true,
				trigger: { player: ['phaseJieshuBegin'] },
				filter: function (event, player) {
					return game.hasPlayer(function (current) {
						return current != player && current.group == 'qun';
					}) && player.hasZhuSkill('yongquan');
				},
				content: function () {
					'step 0'
					event.nowplayer = player;
					event.player = event.nowplayer.next;
					'step 1'
					if (event.player.group != 'qun') {
						event.goto(3);
					}
					else {
						event.player.chooseCard('你可以将一张手牌交给' + get.translation(event.nowplayer), 'h').set('ai', function (card) {
							if (get.attitude(event.player, event.nowplayer) < 0) return false;
							return 5 - get.value(card);
						});
					}
					'step 2'
					if (result.bool) {
						event.nowplayer.gain(result.cards, event.player, 'giveAuto');
						game.log('#b' + get.translation(event.player), '将一张牌交给了', '#b' + get.translation(event.nowplayer));
					}
					'step 3'
					event.player = event.player.next;
					if (event.player == event.nowplayer) event.finish();
					else event.goto(1);
				}
			},

			//kun
			tieji: {
				shaRelated: true,
				audio: 2,
				trigger: { player: 'useCardToPlayered' },
				check: function (event, player) {
					return get.attitude(player, event.target) <= 0;
				},
				filter: function (event, player) {
					return event.card.name == 'sha';
				},
				logTarget: 'target',
				content: function () {
					"step 0"
					player.judge(function () { return 0 });
					if (!trigger.target.hasSkill('fengyin')) {
						trigger.target.addTempSkill('fengyin');
					}
					"step 1"
					var suit = result.suit;
					var target = trigger.target;
					var num = target.countCards('h', 'shan');
					target.chooseToDiscard('请弃置一张' + get.translation(suit) + '牌，否则不能使用闪抵消此杀', 'he', function (card) {
						return get.suit(card) == _status.event.suit;
					}).set('ai', function (card) {
						var num = _status.event.num;
						if (num == 0) return 0;
						if (card.name == 'shan') return num > 1 ? 2 : 0;
						return 8 - get.value(card);
					}).set('num', num).set('suit', suit);
					"step 2"
					if (!result.bool) {
						trigger.getParent().directHit.add(trigger.target);
					}
				},
				ai: {
					ignoreSkill: true,
					skillTagFilter: function (player, tag, arg) {
						if (tag == 'directHit_ai') {
							return get.attitude(player, arg.target) <= 0;
						}
						if (!arg || arg.isLink || !arg.card || arg.card.name != 'sha') return false;
						if (!arg.target || get.attitude(player, arg.target) >= 0) return false;
						if (!arg.skill || !lib.skill[arg.skill] || lib.skill[arg.skill].charlotte || get.is.locked(arg.skill) || !arg.target.getSkills(true, false).contains(arg.skill)) return false;
					},
					directHit_ai: true,
				}
			},
			mashu: {
				mod: {
					globalFrom: function (from, to, distance) {
						return distance - 1;
					}
				}
			},
			mashu2: {
				mod: {
					globalFrom: function (from, to, distance) {
						return distance - 1;
					}
				}
			},
			feiying: {
				mod: {
					globalTo: function (from, to, distance) {
						return distance + 1;
					}
				}
			},

			wuyan:{
				audio:2,
				forced:true,
				trigger: { player: 'phaseJieshuBegin' },
				filter:function(event,player){
					return !player.hasHistory('useCard', function (evt) {
						return get.type(evt.card,'trick')=='trick';
					});
				},
				content:function(){
					player.addTempSkill('wuyan2',{player:'phaseBeginStart'});
				},
				effect: {
					player: function (card, player, target, current) {
						if (get.type(card) == 'trick') {
							if(player.countCards('h')<3||player.hp==1)
							return 'zeroplayertarget';
							else return 0.5;
						}
					},
				}
			},
			wuyan2: {
				audio: 'wuyan',
				trigger: { player: 'damageBegin4' },
				forced: true,
				//priority:15,
				check: function (event, player) {
					if (player == event.player) return true;
					return false;
				},
				filter: function (event, player) {
					return get.type(event.card, 'trick') == 'trick'||event.nature=='fire';
				},
				content: function () {
					trigger.cancel();
				},
				mark:true,
				intro:{
					content:'锦囊牌造成的伤害和火焰伤害对其无效',
				},
				ai: {
					notrick: true,
					effect: {
						target: function (card, player, target, current) {
							if (get.type(card) == 'trick' && get.tag(card, 'damage')) {
								return 'zeroplayertarget';
							}
						},
					}
				}
			},
			/*jujian: {
				trigger: { player: 'phaseJieshuBegin' },
				direct: true,
				audio: 2,
				filter: function (event, player) {
					return player.countCards('he') && game.hasPlayer(function (current) {
						return player != current && (current.isLinked() || current.isTurnedOver());
					});
				},
				content: function () {
					"step 0"
					player.chooseCardTarget({
						filterTarget: function (card, player, target) {
							return player != target && (target.isLinked() || target.isTurnedOver());
						},
						filterCard: function (card, player) {
							return lib.filter.cardDiscardable(card, player);
						},
						ai1: function (card) {
							if (get.tag(card, 'damage') && get.type(card) == 'trick') {
								return 20;
							}
							if (card.name == 'du') return -2;
							return 9 - get.value(card);
						},
						ai2: function (target) {
							var att = get.attitude(_status.event.player, target);
							if (att > 0) {
								if (target.isTurnedOver()) att += 3;
								if (target.isLinked()) att += 3;
							}
							return att;
						},
						position: 'he',
						prompt: get.prompt2('jujian')
					});
					"step 1"
					if (result.bool) {
						var target = result.targets[0];
						event.target = target;
						player.logSkill('jujian', target);
						player.discard(result.cards);
					}
					else event.finish();
					'step 2'
					if (event.target.isLinked()) {
						event.target.link(false);
						event.target.recover();
						event.target.draw();
					}
					'step 3'
					if (event.target.isTurnedOver()) {
						event.target.turnOver(false);
						game.asyncDraw([player, event.target]);
					}
				},
				ai: {
					expose: 0.2,
					threaten: 1.4
				}
			},*/
			jujian:{
				audio: 2,
				enable: 'phaseUse',
				usable: 1,
				discard: false,
				lose: false,
				delay: false,
				filter: function (event, player) {
					return player.hp > 0;
				},
				filterCard:function(card){
					return get.type(card)=='trick';
				},
				check:function(card){
					return get.value(card);
				},
				position:'h',
				filterTarget: function (card, player, target) {
					if (player == target) return false;
					return true;
				},
				content: function () {
					'step 0'
					player.showCards(cards);
					targets[0].chooseUseTarget({name:cards[0].name});
					'step 1'
					if(!result.bool){
						player.draw();
					}
				},
				ai: {
					result: {
						target: function (player, target) {
							return get.attitude(player,target)>0;
						},
					},
					order: 9,
				}
			},

			jushou: {
				audio: 2,
				group: ['jushou1'],
				prompt2: function (event, player) {
					var drawevent = player.getHistory('gain', null);
					var num = 0;
					for (var i = 0; i < drawevent.length; i++) {
						var evt = drawevent[i].getParent();
						if (evt.name != 'draw') continue;
						num += evt.num;
					}
					return '结束阶段，你可以摸' + get.cnNumber(Math.min(5, num)) + '张牌，然后翻面。以此法获得的牌可以当【无懈可击】使用。';
				},
				trigger: { player: 'phaseJieshuBegin' },
				check: function (event, player) {
					var drawevent = player.getHistory('gain', null);
					var num = 0;
					for (var i = 0; i < drawevent.length; i++) {
						var evt = drawevent[i].getParent();
						if (evt.name != 'draw') continue;
						num += evt.num;
					}
					if (num > 2) return true;
					return false;
				},
				content: function () {
					'step 0'
					var drawevent = player.getHistory('gain', null);
					var num = 0;
					for (var i = 0; i < drawevent.length; i++) {
						var evt = drawevent[i].getParent();
						if (evt.name != 'draw') continue;
						num += evt.num;
					}
					player.draw(Math.min(5, num));
					'step 1'
					player.addGaintag(result, 'jushou');
					player.addTempSkill('feiying', { player: 'phaseBeginStart' })
					player.turnOver();
				},
				ai: {
					effect: {
						target: function (card, player, target) {
							if (card.name == 'guiyoujie') return [0, 1];
						}
					}
				},
			},
			jushou1: {
				audio: 2,
				mod: {
					aiValue: function (player, card, num) {
						if (get.name(card) != 'wuxie' && !card.hasGaintag('jushou')) return;
						var cards = player.getCards('hs', function (card) {
							return get.name(card) == 'wuxie' || card.hasGaintag('jushou');
						});
						cards.sort(function (a, b) {
							return (get.name(b) == 'wuxie' ? 1 : 2) - (get.name(a) == 'wuxie' ? 1 : 2);
						});
						var geti = function () {
							if (cards.contains(card)) {
								return cards.indexOf(card);
							}
							return cards.length;
						};
						if (get.name(card) == 'wuxie') return Math.min(num, [6, 4, 3][Math.min(geti(), 2)]) * 0.6;
						return Math.max(num, [6, 4, 3][Math.min(geti(), 2)]);
					},
					aiUseful: function () {
						return lib.skill.kanpo.mod.aiValue.apply(this, arguments);
					},
				},
				locked: false,
				position: "h",
				enable: "chooseToUse",
				filterCard: function (card) {
					return card.hasGaintag('jushou');
				},
				viewAsFilter: function (player) {
					return player.countCards('hes', function (card) {
						return card.hasGaintag('jushou');
					}) > 0;
				},
				viewAs: {
					name: "wuxie",
				},
				prompt: "将一张因“据守”获得的牌当无懈可击使用",
				check: function (card) { return 8 - get.value(card) },
			},

			luoying: {
				//unique:true,
				//gainable:true,
				group: ['luoying_discard', 'luoying_judge'],
				subfrequent: ['judge'],
				subSkill: {
					discard: {
						audio: 2,
						trigger: { global: 'loseAfter' },
						filter: function (event, player) {
							if (event.type != 'discard') return false;
							if (event.player == player) return false;
							for (var i = 0; i < event.cards2.length; i++) {
								if (get.suit(event.cards2[i], event.player) == 'club' && get.position(event.cards2[i], true) == 'd') {
									return true;
								}
							}
							return false;
						},
						direct: true,
						//frequent:'check',
						content: function () {
							"step 0"
							if (trigger.delay == false) game.delay();
							"step 1"
							var cards = [];
							for (var i = 0; i < trigger.cards2.length; i++) {
								if (get.suit(trigger.cards2[i], trigger.player) == 'club' && get.position(trigger.cards2[i], true) == 'd') {
									cards.push(trigger.cards2[i]);
								}
							}
							if (cards.length) {
								player.chooseButton(['落英：选择要获得的牌', cards], [1, cards.length]).set('ai', function (button) {
									return get.value(button.link, _status.event.player, 'raw');
								});
							}
							"step 2"
							if (result.bool) {
								player.logSkill(event.name);
								player.gain(result.links, 'gain2', 'log');
							}
						},
					},
					judge: {
						audio: 2,
						trigger: { global: 'cardsDiscardAfter' },
						//frequent:'check',
						direct: true,
						filter: function (event, player) {
							var evt = event.getParent().relatedEvent;
							if (!evt || evt.name != 'judge') return;
							if (evt.player == player) return false;
							if (get.position(event.cards[0], true) != 'd') return false;
							return (get.suit(event.cards[0]) == 'club');
						},
						content: function () {
							"step 0"
							player.chooseButton(['落英：选择要获得的牌', trigger.cards], [1, trigger.cards.length]).set('ai', function (button) {
								return get.value(button.link, _status.event.player, 'raw');
							});
							"step 1"
							if (result.bool) {
								player.logSkill(event.name);
								player.gain(result.links, 'gain2', 'log');
							}
						}
					}
				}
			},
			jiushi: {
				audio: 'jiushi1',
				group: ['jiushi1', 'jiushi2', 'jiushi3'],
			},
			jiushi1: {
				audio: 2,
				enable: 'chooseToUse',
				hiddenCard: function (player, name) {
					if (name == 'jiu') return !player.isTurnedOver();
					return false;
				},
				filter: function (event, player) {
					if (player.classList.contains('turnedover')) return false;
					return event.filterCard({ name: 'jiu', isCard: true }, player, event);
				},
				content: function () {
					if (_status.event.getParent(2).type == 'dying') {
						event.dying = player;
						event.type = 'dying';
					}
					player.turnOver();
					player.useCard({ name: 'jiu', isCard: true }, player);
				},
				ai: {
					order: 5,
					result: {
						player: function (player) {
							if (_status.event.parent.name == 'phaseUse') {
								if (player.countCards('h', 'jiu') > 0) return 0;
								if (player.getEquip('zhuge') && player.countCards('h', 'sha') > 1) return 0;
								if (!player.countCards('h', 'sha')) return 0;
								var targets = [];
								var target;
								var players = game.filterPlayer();
								for (var i = 0; i < players.length; i++) {
									if (get.attitude(player, players[i]) < 0) {
										if (player.canUse('sha', players[i], true, true)) {
											targets.push(players[i]);
										}
									}
								}
								if (targets.length) {
									target = targets[0];
								}
								else {
									return 0;
								}
								var num = get.effect(target, { name: 'sha' }, player, player);
								for (var i = 1; i < targets.length; i++) {
									var num2 = get.effect(targets[i], { name: 'sha' }, player, player);
									if (num2 > num) {
										target = targets[i];
										num = num2;
									}
								}
								if (num <= 0) return 0;
								var e2 = target.getEquip(2);
								if (e2) {
									if (e2.name == 'tengjia') {
										if (!player.countCards('h', { name: 'sha', nature: 'fire' }) && !player.getEquip('zhuque')) return 0;
									}
									if (e2.name == 'renwang') {
										if (!player.countCards('h', { name: 'sha', color: 'red' })) return 0;
									}
									if (e2.name == 'baiyin') return 0;
								}
								if (player.getEquip('guanshi') && player.countCards('he') > 2) return 1;
								return target.countCards('h') > 3 ? 0 : 1;
							}
							if (player == _status.event.dying || player.isTurnedOver()) return 3;
						}
					},
					effect: {
						target: function (card, player, target) {
							if (card.name == 'guiyoujie') return [0, 0.5];
							if (target.isTurnedOver()) {
								if (get.tag(card, 'damage')) {
									if (player.hasSkillTag('jueqing', false, target)) return [1, -2];
									if (target.hp == 1) return;
									return [1, target.countCards('h') / 2];
								}
							}
						}
					}
				},
			},
			jiushi2: {
				trigger: { player: 'damageBegin3' },
				silent: true,
				firstDo: true,
				filter: function (event, player) {
					return player.classList.contains('turnedover');
				},
				content: function () {
					trigger.jiushi = true;
				}
			},
			jiushi3: {
				audio: 'jiushi1',
				trigger: { player: 'damageEnd' },
				check: function (event, player) {
					return player.isTurnedOver();
				},
				prompt: '是否发动【酒诗】，将武将牌翻面？',
				filter: function (event, player) {
					if (event.jiushi) {
						return true;
					}
					return false;
				},
				content: function () {
					delete trigger.jiushi;
					player.turnOver();
				}
			},

			buqu: {
				audio: 2,
				audioname: ['key_yuri'],
				trigger: { player: 'chooseToUseBefore' },
				forced: true,
				preHidden: true,
				filter: function (event, player) { return event.type == 'dying' && player.isDying() && event.dying == player },
				content: function () {
					"step 0"
					event.card = get.cards()[0];
					if (player.storage.buqu == undefined) player.storage.buqu = [];
					player.storage.buqu.push(event.card);
					player.syncStorage('buqu');
					//event.trigger("addCardToStorage");
					game.cardsGotoSpecial(event.card);
					player.showCards(player.storage.buqu, '不屈')
					player.markSkill('buqu');
					"step 1"
					for (var i = 0; i < player.storage.buqu.length - 1; i++) {
						if (get.number(event.card) && get.number(event.card) == get.number(player.storage.buqu[i])) {
							player.storage.buqu.remove(event.card);
							player.syncStorage('buqu');
							player.markSkill('buqu');
							game.cardsDiscard(event.card);
							return;
						};
					}
					trigger.cancel();
					trigger.result = { bool: true };
					if (player.hp <= 0) {
						player.recover(1 - player.hp);
					}
				},
				mod: {
					maxHandcardBase: function (player, num) {
						if (get.mode() != 'guozhan' && player.storage.buqu && player.storage.buqu.length) return player.storage.buqu.length;
					},
				},
				ai: {
					save: true,
					mingzhi: true,
					skillTagFilter: function (player, tag, target) {
						if (player != target) return false;
					},
				},
				intro: {
					content: 'cards',
					onunmark: function (storage, player) {
						if (storage && storage.length) {
							player.$throw(storage, 1000);
							game.cardsDiscard(storage);
							delete player.storage.buqu;
						}
					}
				}
			},
			fenji: {
				audio: 2,
				trigger: {
					global: "phaseJieshuBegin",
				},
				filter: function (event, player) {
					if (event.player.countCards('h') == 0 && event.player.isAlive() && !player.isTurnedOver()) return true;
					return false;
				},
				preHidden: true,
				direct: true,
				content: function () {
					'step 0'
					var list = ['失去1点体力'];
					if (player.storage.buqu && player.storage.buqu.length) list.push('弃置一张“创”并翻面');
					player.chooseControl(list).set('prompt', '奋激：请选择一项').set('ai', function (event, player) {
						if (get.attitude(player, event.getTrigger().player) < 2) return false;
						if (player.storage.buqu && player.storage.buqu.length >= 4) return 1;
						return 0;
					})
					'step 1'
					if (result.control == '失去1点体力') {
						player.logSkill('fenji');
						player.line(trigger.player, 'green');
						trigger.player.draw(2);
						player.loseHp();
					}
					else if (result.control == '弃置一张“创”并翻面') {
						player.logSkill('fenji');
						player.chooseButton(['弃置一张“创”', [player.storage.buqu, 'vcard']], true).set('ai', function (button) {
							return 1;
						});
					}
					else event.finish();
					'step 2'
					if (result.bool) {
						var card = result.links[0];
						player.storage.buqu.remove(card);
						game.log(player, '弃置了“创”', card);
						player.syncStorage('buqu');
						player.markSkill('buqu');
						game.cardsDiscard(card);
						player.line(trigger.player, 'green');
						trigger.player.draw(2);
						player.turnOver();
					}
				},
			},

			zhijian: {
				audio: 2,
				enable: 'phaseUse',
				usable: 2,
				filter: function (event, player) {
					return player.countCards('h', function (card) {
						return get.type(card) == 'equip' || get.cardCanDelay(card) || get.type(card) == 'delay';
					}) > 0;
				},
				filterCard: function (card) {
					return get.type(card) == 'equip' || get.cardCanDelay(card) || get.type(card) == 'delay';
				},
				check: function (card) {
					var player = _status.currentPhase;
					if (player.countCards('he', { type: 'equip', subtype: get.subtype(card) }) > 1) {
						return 11 - get.equipValue(card);
					}
					if (player.countCards('h', function (card) {
						return get.cardCanDelay(card) || get.type(card) == 'delay';
					})) {
						return get.value(card);
					}
					return 6 - get.value(card);
				},
				filterTarget: function (card, player, target) {
					if (get.type(card) == 'equip') {
						if (target.isMin()) return false;
						var type = get.subtype(card);
						return player != target && target.isEmpty(type);
					}
					else if (get.cardCanDelay(card, player) || get.type(card) == 'delay') {
						return player != target && target.canAddJudge({ name: card.name + '_delay' });
					}
				},
				content: function () {
					if (get.type(cards[0]) == 'equip') target.equip(cards[0]);
					else if (get.type(cards[0]) == 'delay') target.addJudge(cards[0]);
					else if (get.cardCanDelay(cards[0], player)) target.addJudge({ name: cards[0].name + '_delay' }, [cards[0]], player);
					player.draw();
				},
				discard: false,
				prepare: function (cards, player, targets) {
					player.$give(cards, targets[0], false);
				},
				ai: {
					basic: {
						order: 10
					},
					result: {
						target: function (player, target) {
							var card = ui.selected.cards[0];
							if (card) return get.effect(target, card, target, target);
							return 0;
						},
					},
					threaten: 1.3
				}
			},
			guzheng: {
				audio: 2,
				trigger: { global: 'phaseDiscardAfter' },
				filter: function (event, player) {
					if (event.player != player && event.player.isIn()) {
						return event.player.getHistory('lose', function (evt) {
							return evt.type == 'discard' && evt.getParent('phaseDiscard') == event && evt.hs.filterInD('d').length > 0;
						}).length > 0;
					}
					return false;
				},
				checkx: function (event, player, cards, cards2) {
					if (cards.length > 2 || get.attitude(player, event.player) > 0) return true;
					for (var i = 0; i < cards2.length; i++) {
						if (get.value(cards2[i], event.player, 'raw') < 0) return true;
					}
					return false;
				},
				direct: true,
				preHidden: true,
				content: function () {
					"step 0"
					var cards = [];
					var cards2 = [];
					game.getGlobalHistory('cardMove', function (evt) {
						if (evt.name == 'cardsDiscard' && evt.getParent('phaseDiscard') == trigger) cards.addArray(evt.cards.filterInD('d'));
					});
					game.countPlayer2(function (current) {
						current.getHistory('lose', function (evt) {
							if (evt.type != 'discard' || evt.getParent('phaseDiscard') != trigger) return;
							cards.addArray(evt.cards.filterInD('d'));
							if (current == trigger.player) cards2.addArray(evt.hs.filterInD('d'));
						})
					});
					event.cards = cards;
					var check = lib.skill.guzheng.checkx(trigger, player, cards, cards2);
					player.chooseCardButton(cards, '固政：选择令' + get.translation(trigger.player) + '收回的牌').set('ai', function (button) {
						if (_status.event.check) {
							return 20 - get.value(button.link, _status.event.getTrigger().player);
						}
						return 0;
					}).set('check', check).set('cards', cards2).set('filterButton', function (button) {
						return _status.event.cards.contains(button.link);
					}).setHiddenSkill(event.name);
					"step 1"
					if (result.bool) {
						game.delay(0.5);
						player.logSkill('guzheng', trigger.player);
						trigger.player.gain(result.links[0]);
						trigger.player.$gain2(result.links[0]);
						game.log(trigger.player, '收回了', result.links[0]);
						event.cards.remove(result.links[0]);
						if (event.cards.length) {
							player.gain(event.cards);
							player.$gain2(event.cards);
							game.log(player, '收回了', event.cards);
						}
						game.delay();
					}
				},
				ai: {
					threaten: 1.3,
					expose: 0.2
				}
			},

			yaowu: {
				trigger: { player: 'damageBegin3' },
				audio: 2,
				forced: true,
				filter: function (event) {
					return event.card && (get.color(event.card) != 'red' || event.source && event.source.isAlive()) && event.num;
				},
				content: function () {
					if (get.color(trigger.card) == 'red') {
						trigger.source.draw();
					}
					else if (get.color(trigger.card) == 'black') {
						if (trigger.player.isTurnedOver()) trigger.player.draw(2);
						else trigger.player.draw();
					}
				},
				ai: {
					effect: function (card, player, target) {
						if (get.tag(card, 'damage') && get.color(card) == 'black' && target.isTurnedOver) return [1, 1.5];
						if (get.tag(card, 'damage') && get.color(card) == 'black') return [1, 0.55];
						if (get.tag(card, 'damage') && get.color(card) == 'red') return [1, -1];
					}
				}
			},
			shiyong: {
				audio: 2,
				enable: 'phaseUse',
				usable: 1,
				filterTarget: function (card, player, target) {
					return player != target && player.canUse({ name: 'sha' }, target, false);
				},
				content: function () {
					player.useCard({ name: 'sha', isCard: true }, target, false).audio = false;
					player.turnOver();
				},
				discard: false,
				ai: {
					basic: {
						order: 10
					},
					result: {
						target: function (player, target) {
							var eff=get.effect(target,{name:'sha'},player,target);
							var damageEff=get.damageEffect(target,player,player);
							if(eff>0) return damageEff>0?0:eff;
							if(target.hasSkill('bagua_skill')||target.hasSkill('rw_bagua_skill')||target.hasSkill('bazhen')) return 0;
							return eff;
						},
						player: function (player, target) {
							if (!player.isTurnedOver()) return 5;
							if (player.hp == 1) return -5;
						}
					},
					threaten: 1.3
				}
			},
			fankui: {
				audio: 2,
				trigger: { player: 'damageEnd' },
				frequent: true,
				content: function () {
					"step 0"
					event.cards = get.cards(3);
					player.showCards(event.cards);
					game.cardsGotoOrdering(event.cards);
					"step 1"
					var cards = [];
					for (var i = 0; i < event.cards.length; i++)
						if (get.cardCanDelay(event.cards[i], player) || event.cards[i].name == 'shan' || event.cards[i].name == 'wuxie') cards.push(event.cards[i]);
					if (cards.length) player.gain(cards, 'gain2');
				},
				ai: {
					maixie_defend: true,
					effect: {
						target: function (card, player, target) {
							if (get.tag(card, 'damage')) {
								if (player.hasSkillTag('jueqing', false, target)) return [1, -1.5];
								if (get.attitude(target, player) < 0) return [1, 0.5];
							}
						}
					}
				}
			},
			/*	fankui:{
					audio:2,
					trigger:{player:'damageEnd'},
					direct:true,
					filter:function(event,player){
						return (event.source&&event.source.countGainableCards(player,'he')&&event.num>0&&event.source!=player);
					},
					content:function(){
						"step 0"
						event.count=trigger.num;
						"step 1"
						event.count--;
						player.gainPlayerCard(get.prompt('fankui',trigger.source),trigger.source,get.buttonValue,'he').set('logSkill',[event.name,trigger.source]);
						"step 2"
						if(result.bool&&event.count>0&&trigger.source.countGainableCards(player,'he')>0) event.goto(1);
					},
					ai:{
						maixie_defend:true,
						effect:{
							target:function(card,player,target){
								if(player.countCards('he')>1&&get.tag(card,'damage')){
									if(player.hasSkillTag('jueqing',false,target)) return [1,-1.5];
									if(get.attitude(target,player)<0) return [1,1];
								}
							}
						}
					}
				},*/
			quanbian: {
				audio: 2,
				trigger: { player: 'useCardAfter' },
				direct: true,
				filter: function (event, player) {
					return get.info(event.card).isdelay;
				},
				content: function () {
					var name = trigger.card.name.replace(/_delay/g, '');
					if (name == 'guagu') name = 'guaguliaodu';
					player.chooseUseTarget({ name: name }, false, 'noTargetDelay', 'nodelayx').set('prompt', get.translation('quanbian')).set('prompt2', '是否对目标使用' + get.translation(name) + '？').set('logSkill', 'quanbian');
				},
				ai: {
					threaten: 2,
				}
			},
		},
		challenge: {
		},
		dynamicTranslate: {
		},
		translate: {
			//qian
			menghuo: '孟获',
			pangtong: '庞统',
			xiahouyuan: '夏侯渊',
			xunyu: '荀彧',
			taishici: '太史慈',
			yufan: '虞翻',
			diaochan: '貂蝉',
			dongzhuo: '董卓',

			huoshou: '祸首',
			huoshou1: '祸首',
			huoshou2: '祸首',
			huoshou5: '祸首',
			huoshou_info: '锁定技，【南蛮入侵】对你无效。当其他角色因响应你使用的【南蛮入侵】而打出【杀】时，其摸一张牌；当你的【南蛮入侵】结算结束后，若不少于两名角色因此牌受到伤害，你摸一张牌或回复一点体力。',
			zaiqi: '再起',
			zaiqi1: '再起',
			zaiqi_info: '游戏开始时，你获得七个“起”标记。每回合限一次，你可以在以下时机移除一个“起”标记并将一张手牌当做【南蛮入侵】使用：你的出牌阶段开始时；进入濒死状态时。',

			tianmou: '天谋',
			tianmou_info: '出牌阶段限一次，你可以与一名角色拼点：若你赢，你从【过河拆桥】、【火攻】、【铁索连环】中选择一张并视为使用之；若没赢，本回合你不能使用锦囊牌。',
			niepan: '涅槃',
			niepan_info: '限定技，当你处于濒死状态时，你可以弃置区域里的所有牌，然后复原你的武将牌，摸三张牌，将体力回复至3点。',

			shensu: '神速',
			shensu_info: '你可以做出如下选择：1.跳过判定阶段和摸牌阶段；2.跳过出牌阶段并弃置一张装备牌。你每选择一项，便视为你使用一张无距离限制的【刺杀】。',

			quhu: '驱虎',
			quhu_info: '出牌阶段限一次，你可以与体力值大于你的一名角色拼点：若你赢，你令该角色对其攻击范围内的另一名角色造成1点自适应伤害；若你没赢，其对你造成1点伤害。',
			jieming: '节命',
			jieming_info: '当你受到1点伤害后，你可以令一名角色将手牌摸至X张（X为其体力上限且最多为5）。',

			tianyi: '天义',
			tianyi_info: '出牌阶段限一次，你可以与一名角色拼点：若你赢，本回合你可以多使用一张【杀】、使用【杀】无距离限制且可以多选择一个目标；若你没赢，本回合你不能使用【杀】。然后，你获得拼点牌中的【杀】。',

			zongxuan: '纵玄',
			zongxuan_info: '锁定技，你的手牌上限-2。当你的牌因弃置而置入弃牌堆后，你须将其中至少一张牌置于牌堆顶。',
			zhiyan: '直言',
			zhiyan_info: '结束阶段，你可以令一名本回合此技能未选择过的角色亮出牌堆顶的一张牌，若此牌为：基本牌，其选择一项：1.其获得该牌，然后你可以重复此流程；2.令你摸两张牌；非基本牌，其选择一项：1.其弃置一张牌，然后你可以重复此流程；2.令你获得此牌并摸两张牌。',

			lijian: '离间',
			lijian_info: '出牌阶段限一次，你可以弃置一张手牌并选择一项：1.令一名男性角色与另一名男性角色拼点；2.令一名男性角色视为对另一名男性角色使用一张【决斗】。',
			biyue: '闭月',
			biyue_info: '结束阶段，你可以摸X张牌（X为当前轮数减去上一次发动“闭月”的轮数）。',

			tuicheng: '推诚',
			tuicheng_info: '出牌阶段限一次，你可以失去1点体力，然后视为使用一张【推心置腹】 。',
			yaoling: '耀令',
			yaoling_info: '出牌阶段结束时，你可以失去一点体力上限，然后令一名其他角色对令一名由你指定的角色使用一张【杀】，若其拒绝，你可以弃置其一张牌 。',
			shicha: '失察',
			shicha_info: '锁定技，弃牌阶段开始时，若你本回合未发动过“推诚”或“耀令”，你本回合手牌上限为1 。',
			yongquan: '拥权',
			yongquan_info: '主公技，结束阶段，其他群雄角色可以依次将一张手牌交给你。',

			machao: '马超',
			xushu: '徐庶',
			caoren: '曹仁',
			caozhi: '曹植',
			zhoutai: '周泰',
			zhangzhaozhanghong: '张昭张纮',
			huaxiong: '华雄',
			simayi: '司马懿',

			tieji: '铁骑',
			tieji_info: '当你使用【杀】指定目标后，你可令其本回合非锁定技失效，然后你进行判定，除非其弃置与结果花色相同的一张牌，否则不能使用【闪】闪避此【杀】。',
			mashu: '马术',
			mashu_info: '锁定技，你计算与其他角色的距离时-1。',
			mashu2: '马术',
			mashu2_info: '锁定技，你计算与其他角色的距离时-1。',
			feiying: '飞影',
			feiying_info: '锁定技，其他角色计算与你的距离时+1。',

			wuyan: '无言',
			wuyan2:'无言',
			wuyan_info:'锁定技，结束阶段，若你本回合内没有使用或延迟使用锦囊牌，锦囊牌造成的伤害和火焰伤害对你无效直到你的下个回合开始。',
		//	wuyan_info: '锁定技，当你使用锦囊牌造成伤害时，防止此伤害；当你受到锦囊牌造成的伤害时，防止此伤害。',
			jujian: '举荐',
			jujian_info:'出牌阶段限一次，你可以选择一名其他角色并展示一张普通锦囊牌，其需视为使用一张与此牌名相同的牌，否则令你摸一张牌。',
		//	jujian_info: '结束阶段，你可以弃置一张牌并令一名其他角色复原武将牌，若其进行了：重置，其回复一点体力并摸一张牌；将武将牌翻转至正面朝上，你与其各摸一张牌。',

			jushou: '据守',
			jushou1: '据守',
			jushou_info: '结束阶段，你可以摸X张牌，然后翻面并获得“飞影”直到下个回合开始。以此法获得的牌可以当【无懈可击】使用（X为你本回合内摸牌数量且最多为5）。',

			luoying: '落英',
			luoying_info: '当其他角色的一张梅花牌因弃置或判定而置入弃牌堆时，你可以获得之。',
			jiushi: '酒诗',
			jiushi1: '酒诗',
			jiushi2: '酒诗',
			jiushi3: '酒诗',
			jiushi_info: '当你需要使用【酒】时，若武将牌正面朝上，可以翻面，视为使用一张【酒】。当你受到伤害后，若武将牌背面朝上，可以翻面。',

			buqu: '不屈',
			buqu_info: '锁定技，当你处于濒死状态时，你将牌堆顶的一张牌置于你的武将牌上，称为“创”。若没有与此“创”点数相同的其他“创”，你将体力回复至1点；若有与此“创”点数相同的其他“创”，你将此“创”置入弃牌堆。若有“创”，你的手牌上限为X（X为“创”数）。',
			fenji: '奋激',
			fenji_info: '一名角色的回合结束时，若其没有手牌且你的武将牌正面朝上，你可以令其摸两张牌。若如此做，你：失去1点体力；弃置一张“创”并翻面。',

			zhijian: '直谏',
			zhijian_info: '出牌阶段限两次，你可以将手牌中的一张装备牌或延时牌置于其他角色的对应区域里，然后摸一张牌。',
			guzheng: '固政',
			guzheng_info: '其他角色的弃牌阶段结束时，你可以将该角色此阶段弃置的一张手牌交给该角色，然后你可以获得其余此阶段弃置的牌。',

			yaowu: '耀武',
			yaowu_info: '锁定技，当你受到伤害时，若造成伤害的牌：为红色，伤害来源摸一张牌；为黑色，你摸一张牌，若你武将牌背面朝上，改为摸两张牌。',
			shiyong: '恃勇',
			shiyong_info: '出牌阶段限一次，你可以将武将牌翻面，然后视为使用一张无距离限制的【杀】。',

			fankui: '反馈',
			//	fankui_info:'当你受到1点伤害后，你可以获得伤害来源的一张牌。',
			fankui_info: '当你受到伤害后，你可以从牌堆顶亮出三张牌，然后获得其中的【闪】、【无懈可击】和半延时牌。',
			quanbian: '权变',
			quanbian_info: '当你延迟使用一张牌后，你可以视为使用一张此牌名的半延时牌。',

			classic_qian: '乾',
			classic_kun: '坤',
		},
	};
});
